package com.atguigu.job;

import com.atguigu.util.QiniuUtils;
import com.atguigu.util.RedisConstant;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.Iterator;
import java.util.Set;

public class JobDemo {

    @Autowired
    JedisPool jedisPool;

    public void run(){



        Set<String> sdiff = jedisPool.getResource().sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);
//        if(sdiff.size() > 0){
//            Iterator<String> iterator = sdiff.iterator();

//            while (iterator.hasNext()){
////                try {
////                    System.out.println("删除->"+ iterator.next());
////                    resource.srem(RedisConstant.SETMEAL_PIC_RESOURCES,iterator.next());
////                    QiniuUtils.deleteFileFromQiniu(iterator.next());
////                } catch (Exception e) {
////                    e.printStackTrace();
////                }
////            }
        for (String s : sdiff) {
            jedisPool.getResource().srem(RedisConstant.SETMEAL_PIC_RESOURCES,s);
            System.out.println("删除成功-> = " + s);
            QiniuUtils.deleteFileFromQiniu(s);
        }

//
//        }

    }
}
